﻿using BHan.VM.MenuVM;
using System.Windows;
using System.Windows.Controls;

namespace BHan.View.VMenu
{
    /// <summary>
    /// WindowMenuEdit.xaml 的交互逻辑
    /// </summary>
    public partial class WindowMenuEdit : System.Windows.Window
    {
        private readonly PageMenuVM vm;

        public WindowMenuEdit(PageMenuVM menuVM)
        {
            InitializeComponent();
            vm = menuVM;
            this.DataContext = vm;
        }

        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(menuName.Text) && !string.IsNullOrEmpty(path.Text) && !string.IsNullOrEmpty(status.Text)) {
                this.DialogResult = true;
            }
            else
            {
                HandyControl.Controls.MessageBox.Success("必填项不能为空！");
            }
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        private void TypeChick(object sender, RoutedEventArgs e)
        {
            RadioButton radioButton = (RadioButton)sender;
            if (radioButton.Name.Equals("content"))
            {
                vm.menuModel.menuType = "C";
            }
            if (radioButton.Name.Equals("menu"))
            {
                vm.menuModel.menuType = "M";
            }
            if (radioButton.Name.Equals("btn"))
            {
                vm.menuModel.menuType = "B";
            }
        }

    }
}
